package com.itheima.day14.ZuoYe.ZuoYe3;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        String info = "10001,张无忌,男,2023-07-22 11:11:12,东湖-黄鹤楼" +
                "#10002,赵敏,女,2023-07-22 09:11:21,黄鹤楼-归元禅寺" +
                "#10003,周芷若,女,2023-07-22 04:11:21,木兰文化区-东湖" +
                "#10004,小昭,女,2023-07-22 08:11:21,东湖" +
                "#10005,灭绝,女,2023-07-22 17:11:21,归元禅寺" ;
        String[] infos = info.split("#");
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String[] infos2 = new String[0];
        List<Stus> list = new ArrayList<>();
        for (int i = 0; i < infos.length; i++) {
            infos2 = infos[i].split(",");
            Stus s = new Stus(Long.parseLong(infos2[0]),infos2[1],infos2[2], LocalDateTime.parse(infos2[3],dtf),infos2[4]);
            list.add(s);
            }
        System.out.println(list);
        Map<String,Integer> places = new HashMap<>();
        for (int i = 0; i < list.size(); i++) {
            String[] didian = list.get(i).getPlace().split("-");
            for (int i1 = 0; i1 < didian.length; i1++) {
                if(places.containsKey(didian[i1])){
                places.put(didian[i1],places.get(didian[i1])+1);
                }else{
                    places.put(didian[i1],1);
                }
            }
        }
        places.forEach((k,v)->{
            System.out.println(k+"---"+v);
        });
        System.out.println(places.entrySet().stream().max((o1, o2) -> o1.getValue() - o2.getValue()));
    }
        }
